<?php
/**
 * @author Thibaut Cromphaut, Gaïtano Boeraeve, Mathias Helin, Dimitry Dierickx
 * @copyright  Copyright (c) 2011 Artevelde University College Ghent 
 */

class Application_Form_EditProfile extends Zend_Form
{
    public function init()
    {
        $this->setAttrib('enctype', 'multipart/form-data');
        
        $this->addElement('hidden', 'user_id', array(
            'value'      => null,
        ));

        $this->addElement(new Application_Form_Element_TitleSelect('user_title', array(
            'label'      => 'Title',
            'required'   => false,
            'filters'    => array('StringTrim')
        )));
        
        $this->addElement('text', 'user_givenname', array(
            'label'      => 'Givenname',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(1, 45)),
            ),
        ));
        
        $this->addElement('text', 'user_familyname', array(
            'label'      => 'Familyname',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(1, 45)),
            ),
        ));
        
        $this->addElement(new Application_Form_Element_UserEmail('user_primary_email', array(
            'label'      => 'Email',
            'required'   => true,
            'value'      => "***1",
            'filters'    => array('StringTrim'),
            'validators' => array(new Ahs_Validators_UserEmail()),
        )));
        
        $this->addElement('password', 'user_password', array(
            'label'      => 'Password',
            'required'   => false,
            'filters'    => array('StringTrim'),
            'validators' => array(
                'Alnum',
                array('StringLength', false, array(8, 45)),
            ),
        ));
        
        $this->addElement('text', 'user_dob', array(
            'label'      => 'Date of birth',
            'required'   => false,
            'filters'    => array('StringTrim'),
            'validators' => array(
                'date',
            ),
        ));
        
        $this->addElement('textarea', 'user_bio', array(
            'label'      => 'Biography',
            'rows'       => '5',
            'required'   => false,
            'filters'    => array('StringTrim'),
        ));
        
        $this->addElement(new Application_Form_Element_SecretQuestionSelect('user_secretquestion_id', array(
            'label'      => 'Secret question',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                new Zend_Validate_Regex('/^[0-9]+$/'),
            ),
        )));
        
        $this->addElement('text', 'user_secretanswer', array(
            'label'      => 'Secret answer',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(1, 45)),
            ),
        ));
        
        $this->addElement('file', 'user_avatar', array(
            'label'      => 'Avatar',
            'required'   => false,
            'MaxFileSize'=> 300000,
            'validators' => array(
                array('size', false, 300000),
                array('Extension', false, 'gif,jpg,jpeg,png')
            ),
        ));
        
        $this->addElement('text', 'user_addressline', array(
            'label'      => 'Address',
            'required'   => false,
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(1, 45)),
            ),
        ));
        
        $this->addElement('text', 'user_postalcode', array(
            'label'      => 'Postal code',
            'required'   => false,
            'filters'    => array('StringTrim'),
            'validators' => array(
                'digits',
            ),
        ));
        
        $this->addElement('text', 'user_city', array(
            'label'      => 'City',
            'required'   => false,
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('StringLength', false, array(1, 45)),
            ),
        ));
        
        $this->addElement(new Application_Form_Element_CountrySelect('user_country_id', array(
            'label' => 'Country',
            'required'   => false,
        )));
        
        $this->addElement('submit', 'user_submit', array(
            'label'      => 'Save changes',
        ));

        // CSRF-preventie (Cross-Site Request Forgery)
        $this->addElement('hash', 'no_csrf_registration', array(
            'salt' => 'unique',
        ));
    }

}



